package com.qf.web_last.Service.ServiceImpl;

import com.github.pagehelper.PageHelper;
import com.qf.web_last.Entirty.User;
import com.qf.web_last.Entirty.UserDTO;
import com.qf.web_last.Mapper.UserMapper;
import com.qf.web_last.Service.UserService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 宝剑锋自磨砺出，梅花香自苦寒来
 *
 * @Author:mchao
 * @Time:2025/9/29
 */
@Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(UserDTO userDTO) {
        return userMapper.login(userDTO);
    }




    @Override
    public int getUserByUsername(String username) {
        return userMapper.getUserByUsername(username);
    }

    @Override
    public boolean register(UserDTO userDTO) {
        int i=userMapper.getUserByUsername(userDTO.getUsername());
        if (i>0){
            return false;
        }else {
            return userMapper.register(userDTO)>0;
        }
    }

    @Override
    public List<User> getStudents() {
        PageHelper pageHelper=new PageHelper();
        return userMapper.getStudents();
    }

    @Override
    public boolean addStudent(User user) {
        return userMapper.addStudent(user)>0;
    }

    @Override
    public boolean deleteStudent(User user) {
        return userMapper.deleteStudent(user)>0;
    }

    @Override
    public List<User> searchStudent(User user) {
        return userMapper.searchStudent(user);
    }

    @Override
    public boolean updateStudent(User user) {
        return userMapper.updateStudent(user)>0;
    }

    @Override
    public int getStuNumber(Integer sex) {
        return userMapper.getStuNumber(sex);
    }


}
